package ui;

import java.util.Date;
import java.util.Vector;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

import manager.AgentManagerMIDlet;


public class GetDestinationStartScreen extends Form implements CommandListener{
    private final AgentManagerMIDlet midlet;
    //private final Form fmMain;
    //private final TextBox tbAction;
    private final Command exitCommand;
    private final Command myCommand1;
    private final Command myCommand2;
    private final Command confirmCommand;
//    private DateField timeEntry;
    private final Display display;
    private ChoiceGroup cgAgentFinal;
    private TextField tfNum;
    private Vector startTimes;
    private Vector endTimes;
    private int meetingLength;

    GetDestinationStartScreen(AgentManagerMIDlet midlet, Display display,
    							Vector startTimes,Vector endTimes,
    							int meetingLength)
    {
        super("Destination entry");
        this.display = display;
        this.midlet = midlet;
        this.startTimes = startTimes;
        this.endTimes = endTimes;
        this.meetingLength = meetingLength;
        
        myCommand1 = new Command("myCommand1", Command.SCREEN, 2);
        myCommand2 = new Command("myCommand2", Command.SCREEN, 3);
        confirmCommand = new Command("Confirm", Command.SCREEN,1);
        exitCommand = new Command("Exit", Command.EXIT, 1);
		tfNum = new TextField("Number of Destinations : ", "" ,5,TextField.NUMERIC);
		this.append(tfNum);
        this.addCommand(confirmCommand);
        this.addCommand(exitCommand);
        this.addCommand(myCommand1);
        this.addCommand(myCommand2);
        this.setCommandListener(this);
    }


    public void commandAction(Command c, Displayable d)
    {
        if (c == exitCommand)
        {
            midlet.exitRequested();
        }else if(c==confirmCommand){
        	int numDestinations = Integer.parseInt(tfNum.getString());
        	System.out.println("numDestinations : " + numDestinations);
        	GetDestinationEntryScreen getDestinationEntryScreen = 
        		new GetDestinationEntryScreen(midlet,display,numDestinations,0,null,startTimes,endTimes,meetingLength);
        	display.setCurrent(getDestinationEntryScreen);
        }
    }
}
